//企业职位详情
import React, { Component } from 'react'
import {
    View,
    Text,
    TouchableOpacity, Alert,
} from 'react-native';

import { Cresumetop_Style as styles } from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import {myAlert} from "../../../util/compatible";
import {fetchRequest} from "../../../util/fetch";
var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;

export default class Cdetailpos_top extends Component {
    render() {
        return (
            <View style={[styles.top_all, {
                width: width * 1,
                elevation: 5,
                shadowColor: 'black',
                shadowOpacity: 1,
                shadowRadius: 5
            }]}>

                <TouchableOpacity activeOpacity={1} style={styles.top_back} onPress={() => { this.props.navigation.goBack() }}>
                    <Icon
                        name={'ios-arrow-back'}
                        size={25}
                        color={'#ffffff'} />
                </TouchableOpacity>

                <Text style={styles.top_text}>职位详情</Text>

                <TouchableOpacity activeOpacity={1} style={styles.top_warn}
                    onPress={() => {
                        Alert.alert(
                            '提示',
                            '确定要删除吗?',
                            [
                                {text: '确定', onPress: () => this.delPostion(this.props.navigation.state.params.postionId)},
                                {text: '取消', onPress: () => {}, style: 'cancel'},
                            ]
                        )
                    }}>
                    <Text style={styles.top_text2}>删除</Text>
                </TouchableOpacity>
            </View >

        )
    }

    delPostion(postionId){
        fetchRequest('Postion/delById.go', 'POST', { postionId: postionId }).then(ret => {
            if (ret.msg === 'ok') {
                this.props.navigation.state.params.deleteRow(postionId);
                this.props.navigation.goBack();
            } else {
                myAlert('删除失败')
            }
        })
    }

}